package com.uw.uwregistry.meta;

import com.alibaba.fastjson.JSON;
import com.uw.uwregistry.constant.UWRegistryConstant;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * 服务信息
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ServiceMeta {

    private String appId;
    private String namespace;
    private String env;
    private String name;

    private Map<String, String> parameters = new HashMap<>();

    public String serviceSign() {
        return String.join(UWRegistryConstant.SEPARATOR, Arrays.asList(appId, namespace, env, name));
    }

    public String toMetas() {
        return JSON.toJSONString(this.getParameters());
    }
}
